package com.jh.user.service;

import cn.jh.common.utils.CommonsUtil;
import com.jh.user.business.BranchbankBussiness;
import com.jh.user.pojo.Branchbank;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@EnableAutoConfiguration
public class BranchbankService {

	private static final Logger log = LoggerFactory.getLogger(BranchbankService.class);
	
	@Autowired
	private BranchbankBussiness branchbankBussiness;
	
	
	/**查询支行信息**/
	@RequestMapping(method=RequestMethod.POST,value="/v1.0/user/branchbank/query")
	public @ResponseBody Object bandcard4Auth(@RequestParam(value = "province") String province,
			@RequestParam(value = "city") String city,
			@RequestParam(value = "bankBranchname") String bankBranchname){
		try {
			List<Branchbank> list = branchbankBussiness.queryInfoBranch(province, city, bankBranchname);
			if(list.size()>0) {
				return CommonsUtil.returnOK(list);
			}else {
				return CommonsUtil.returnError("暂不支持该银行卡");
			}
		}catch (Exception e){
			log.error("BranchbankService.bandcard4Auth,查询支行信息异常=" + e);
			return CommonsUtil.returnError("查询支行信息失败！");
		}
	}
}
